package controller;


import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import vo.ActionForward;
import action.*;

@WebServlet("*.dog")
public class DogFrontController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public DogFrontController() {
        super();
    }

	protected void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String requestURI = request.getRequestURI();
		String contextPath = request.getContextPath();
		String command = requestURI.substring(contextPath.length());
		
		Action action = null;
		ActionForward forward = null;
		
		
		
		if(command.equals("/doglist.dog")) {
			action = new DogListAction();
			try {
				forward = action.execute(request, response);
			} catch (Exception e) { e.printStackTrace(); }
			
		} else if (command.equals("/dogView.dog")) {
			action = new DogViewAction();
			try {
				forward = action.execute(request, response);
			} catch (Exception e) { e.printStackTrace(); }
		}
		
		else if (command.equals("/dogCartAdd.dog")) {
			action = new DogCartAddAction();
			try {
				forward = action.execute(request, response);
			} catch (Exception e) { e.printStackTrace(); }
		}
		
		else if (command.equals("/dogCartList.dog")) {
			action = new DogCartListAction();
			try {
				forward = action.execute(request, response);
			} catch (Exception e) { e.printStackTrace(); }
			
			else if (command.equals("/dogCartRemove.dog")) {
				action = new DogCartRemoveAction();
				try {
					forward = action.execute(request, response);
				} catch (Exception e) { e.printStackTrace(); }
			}
			else if (command.equals("/dogCartQtyUp.dog")) {
				action = new DogCartQtyUpAction();
				try {
					forward = action.execute(request, response);
				} catch (Exception e) { e.printStackTrace(); }
			}
			else if (command.equals("/dogCarQtyDown.dog")) {
				action = new DogCarQtyDownAction();
				try {
					forward = action.execute(request, response);
				} catch (Exception e) { e.printStackTrace(); }
			}
			
			if(forward != null) {
				if(forward.is)
			}
		}
		
		
		
	}


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}

}
